<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="common/head :: htmlhead">
    <link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
</head>
<body>
<style type="text/css">
    #rank{
        display: none;
    }
</style>

<div class="layui-fluid" style="padding: 10px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">网点综合评价</div>
                <div class="layui-card-body" >
                    <div class="layui-form" >
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">网点编号</label>
                                <div class="layui-input-inline">
                                    <select name="wangdian" lay-verify="required" id="wangdian">
                                        <option value="">请选择网点编号</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">请选择月份</label>
                                <div class="layui-input-block">
                                    <input type="text" name="yuefen" lay-verify="required" placeholder=""
                                           autocomplete="off" class="layui-input" id="yuefen">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search" id="search1">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-md7">
            <div class="layui-card" style="height: 510px">
                <div class="layui-card-header">评价雷达图</div>
                <div>
                    <b><p id="mark" style="margin-right: 30px;text-align: right">效率评分：</p></b>
                </div>

                <div class="layui-card-body">
                    <div id="radarChart" style="height: 400px;"></div>
                </div>
            </div>
        </div>
        <div class="layui-col-md5">
            <div class="layui-card" style="height: 510px">
                <div class="layui-card-header">评分推算</div>

                <div>
                    <b><p id="now_mark" style="margin-left: 30px;width:250px;height:25px;float:left">评分推算效率评分：</p></b>
                    <button class="layui-btn" style="float: right; margin-right:30px; height: 25px; line-height:25px" id="reset">重置</button>
                </div>

                <div id="allSlider" style="margin-left: 30px;margin-right: 30px;">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend id="paidanliang">最大派送能力</legend>
                    </fieldset>
                    <div id="slideTest1" class="demo-slider" style="margin-right: 30px"></div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend id="shixiao">派送时效</legend>
                    </fieldset>
                    <div id="slideTest2" class="demo-slider" style="margin-right: 30px"></div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend id="danliang">劳动生产率</legend>
                    </fieldset>
                    <div id="slideTest3" class="demo-slider" style="margin-right: 30px"></div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend id="paijianlv">当日派件率</legend>
                    </fieldset>
                    <div id="slideTest4" class="demo-slider" style="margin-right: 30px"></div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend id="liyonglv">人员利用率</legend>
                    </fieldset>
                    <div id="slideTest5" class="demo-slider" style="margin-right: 30px"></div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                        <legend id="fuhe">工作负荷</legend>
                    </fieldset>
                    <div id="slideTest6" class="demo-slider" style="margin-right: 30px"></div>

                    <div style="margin-top: 20px">
                        <hr>
                        <p style="margin-top:10px">说明：指标数值范围来源于所选时间段数据的最大值与最小值。</p>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <div class="layui-col-md12" style="margin-top: 10px;margin-bottom:10px">
        <div class="layui-card">
            <div class="layui-card-header">经营建议</div>
            <div class="layui-card-body">
                <div id="eval"></div>
                <div id="rank" style="margin-left: 60px; color: #9F9F9F; border-left: 2px solid #9F9F9F; padding-left: 5px">
                    <ul>
                        <li id="load_rank"></li>
                        <li id="staff_rank"></li>
                        <li id="age_rank"></li>
                        <li id="labor_rank"></li>
                        <li id="daily_rank"></li>
                        <li id="max_rank"></li>
                    </ul>
                </div>
                <div id="advice"></div>
                <hr>
                <b><p style="margin-left: 30px;">
                    声明：1.以上相关建议为基于系统效率评价模式提出的参考性建议，各网点请结合实际业务情景、经营状况进行调整。
                </p></b>
                <b><p style="margin-left: 73px;">
                    2.网点效率分数计算方式为熵权法，熵值法是根据各项指标指标值的变异程度来确定指标权数的，这是一种客观赋权法，避免了人为因素带来的偏差。
                </p></b>
                <b><p style="margin-left: 73px;">
                    3.指标分数在相同指标下具有可比性，不具有跨指标可比性。各指标是否需要改进以网点该指标在同规模网点中分数排名百分比为参照（单个指标排名位于60%之后的指标需要改进）。
                </p></b>
            </div>
        </div>
    </div>

    <div class="layui-col-md12" style="margin-top: 10px;margin-bottom:10px">
        <div class="layui-card">
            <div class="layui-card-header">指标说明</div>
            <div class="layui-card-body">
                <b><p style="margin-left: 30px;">工作负荷：快递员实际工作时长与理想工作时长之间的差距。</p></b>
                <b><p style="margin-left: 30px;">人员利用率：人力资源充分使用的程度。</p></b>
                <b><p style="margin-left: 30px;">派送时效：平均完成一单派件与签收所需要的时间。</p></b>
                <b><p style="margin-left: 30px;">劳动生产率：平均一个快递员一天完成的派件量。</p></b>
                <b><p style="margin-left: 30px;">当日派件率：该月中，派送时间与签收时间为同一天的快件占总派件的比例。</p></b>
                <b><p style="margin-left: 30px;">最大派送能力：网点可以在一天内完成的最大派件量。</p></b>
                <hr>
            </div>
        </div>
    </div>

    <div class="layui-col-md12" style="margin-top: 10px">
        <div class="layui-card">
            <div class="layui-card-header">效率评分变化趋势图</div>
            <div class="layui-card-body">
                <div class="layui-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">时间范围</label>
                            <div class="layui-input-block">
                                <input type="text" name="yuefenRange" lay-verify="required" style="width:120%"
                                       placeholder=""
                                       autocomplete="off" class="layui-input" id="yuefenRange">
                            </div>
                        </div>
                        <div class="layui-inline" style="margin-left: 50px">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit
                                    lay-filter="LAY-app-contlist-search4" id="search2">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-header">效率评分</div>
            <div class="layui-card-body">
                <div id="shangquanf_chart" style="height: 400px;"></div>
            </div>
        </div>
    </div>

    <div class="layui-col-md12" style="margin-top: 10px">
        <div class="layui-card">
            <div class="layui-card-header">各指标变化趋势图</div>
            <div class="layui-card-body">
                <div class="layui-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">时间范围</label>
                            <div class="layui-input-block">
                                <input type="text" name="date" lay-verify="required" style="width:120%"
                                       placeholder=""
                                       autocomplete="off" class="layui-input" id="date">
                            </div>
                        </div>
                        <div class="layui-inline" style="margin-left: 50px">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit
                                    lay-filter="LAY-app-contlist-search3" id="search3">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">派送时效变化</div>
                    <div class="layui-card-body">
                        <div id="shixiao_chart" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">当日派件率(%)变化</div>
                    <div class="layui-card-body">
                        <div id="deliveryCountRate_chart" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">劳动生产率变化</div>
                    <div class="layui-card-body">
                        <div id="shengchanlv_chart" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">人员利用率(%)变化</div>
                    <div class="layui-card-body">
                        <div id="deliveryCount_chart" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">工作负荷(%)变化</div>
                    <div class="layui-card-body">
                        <div id="workLength_chart" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
            <!--            <div class="layui-col-md12">-->
            <!--                <div class="layui-card">-->
            <!--                    <div class="layui-card-header">业务量变化</div>-->
            <!--                    <div class="layui-card-body">-->
            <!--                        <div id="yewuliang_chart" style="height: 400px;"></div>-->
            <!--                    </div>-->
            <!--                </div>-->
            <!--            </div>-->
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">当日派件量变化</div>
                    <div class="layui-card-body">
                        <div id="deliveryCountOfDay_chart" style="height: 400px;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script src="/static/layui/layui.js" charset="utf-8"></script>

<script type="text/javascript">
    var a1=0;
    var a2=0;
    var a3=0;
    var a4=0;
    var a5=0;
    var a6=0;

    layui.config({
        base: '/static/lib/' //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['form','laydate','echarts','slider', 'layer'],
        function() {
            var laydate = layui.laydate;
            var form = layui.form;
            var $ = layui.$;
            var slider = layui.slider;

            //默认滑块
            slider.render({
                elem: '#slideTest1'
                ,max: 200
                ,min: 0
                ,input: false
            });

            slider.render({
                elem: '#slideTest2'
                ,max: 300
                ,min: 0
                ,input: false
            });

            slider.render({
                elem: '#slideTest3'
                ,max: 400
                ,min: 0
                ,input: false
            });

            slider.render({
                elem: '#slideTest4'
                ,max: 100
                ,min: 0
                ,input: false
            });

            slider.render({
                elem: '#slideTest5'
                ,max: 100
                ,min: 0
                ,input: false
            });

            slider.render({
                elem: '#slideTest6'
                ,max: 100
                ,min: 0
                ,input: false
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#yuefen' //指定元素
                ,type: 'month'
                ,max: 0
                ,value: '[[${yuefen}]]'
            });

            var echarts = layui.echarts,
                option = {
                    tooltip: {},
                    legend: {
                        data: []
                    },
                    radar: {
                        name: {
                            textStyle: {
                                color: '#fff',
                                backgroundColor: '#999',
                                borderRadius: 3,
                                padding: [3, 5]
                            }
                        },
                        indicator: [
                            { name: '派送时效', max: 100},
                            { name: '工作负荷', max: 100},
                            { name: '人员利用率', max: 100},
                            { name: '劳动生产率', max: 100},
                            { name: '最大派送能力', max: 100},
                            { name: '当日派件率', max: 100},
                        ],
                        center: ['50%', '47%']
                    },
                    series: [{
                        name: '当前网点 vs 最优网点',
                        type: 'radar',
                        // areaStyle: {normal: {}},
                        data: [

                        ]
                    }]
                };
            radarChart= document.getElementById('radarChart')
            mychart= echarts.init(radarChart);
            mychart.setOption(option);

            // 获取orgCodeList
            $.ajax({
                url: '/orgCodeList',
                async: false,
                type: "POST",
                success: function (data) {
                    data = $.parseJSON(data);
                    for (var i = 0; i < data.orgCodeList.length; i++) {
                        document.getElementById("wangdian").options.add(new Option(data.orgCodeList[i], data.orgCodeList[i]));
                    }
                    // render使select重新刷新，否则
                    form.render();
                }
            });

            // yuefen&orgcode有值，即从网点列表直接点进来的情况。
            if ('[[${yuefen}]]' !== null && '[[${yuefen}]]' !== '' && '[[${orgCode}]]' !== null && '[[${orgCode}]]' !== '') {
                $("#yuefen").val('[[${yuefen}]]');
                var select = document.getElementById("wangdian");
                for(var i=0; i<select.options.length; i++){
                    if(select.options[i].innerHTML === '[[${orgCode}]]'){
                        select.options[i].selected = true;
                        break;
                    }
                }
                form.render();

                // 设置timeout，防止冲突（a请求还没完成，b请求已经开始了）
                setTimeout("document.getElementById('search1').click()", 200 );
            }

            form.on('submit(LAY-app-contlist-search)', function(data){
                $.ajax({
                    url:'/get_evaluate?type=zonghe',
                    async: false,
                    type:"POST",
                    dataType: "text",
                    data:data.field,
                    success:function(data){
                        data=$.parseJSON(data);

                        // 修改下面各指标趋势时间
                        laydate.render({
                            elem: '#date' //指定元素
                            , range: true
                            ,max: 0
                            ,value: data.date
                        });
                        // 模拟点击，实现三类图按照默认时间画图
                        $('#search2').click();
                        $('#search3').click();

                        if (data.res.toString() === 'fail') {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }

                        var value_list = [];
                        var shangquan_max_list=[];
                        var now_valuelist = [a2,a4,a1,a3,a5,a6];
                        // var max_list = data.maxAttribute;

                        now_dailyMaxWaybillCount = data.orgmonth.dailyMaxWaybillCount;
                        now_averageAge = data.orgmonth.averageAge;
                        now_waybillNoCount = data.orgmonth.laborProductivity;
                        now_avgDeliveryCountRate = data.orgmonth.avgDeliveryCountRate;
                        now_deliveryRate = data.orgmonth.deliveryRate;
                        now_workload = data.orgmonth.workload;

                        max_averageAge = data.max_averageAge;
                        max_dailyMaxWaybillCount = data.max_dailyMaxWaybillCount;
                        max_waybillNoCount = data.max_laborProductivity;
                        max_avgDeliveryCountRate = data.max_avgDeliveryCountRate;
                        max_deliveryRate = data.max_deliveryRate;
                        max_workload = data.max_workload;

                        min_averageAge = data.min_averageAge;
                        min_dailyMaxWaybillCount = data.min_dailyMaxWaybillCount;
                        min_waybillNoCount = data.min_laborProductivity;
                        min_avgDeliveryCountRate = data.min_avgDeliveryCountRate;
                        min_deliveryRate = data.min_deliveryRate;
                        min_workload = data.min_workload;

                        W_dailyMaxWaybillCount = data.W_dailyMaxWaybillCount;
                        W_averageAge = data.W_averageAge;
                        W_waybillNoCount = data.W_waybillNoCount;
                        W_avgDeliveryCountRate = data.W_avgDeliveryCountRate;
                        W_deliveryRate = data.W_deliveryRate;
                        W_workload = data.W_workload;

                        // 最大熵权法网点 各项得分
                        var sqf1 = 100*(1/data.maxShangquanf.averageAge - 1/max_averageAge) / (1/min_averageAge - 1/max_averageAge);
                        sqf1 = sqf1.toFixed(2);

                        var sqf2;
                        if(data.maxShangquanf.workload < 100) sqf2 = (data.maxShangquanf.workload-min_workload)/(100-min_workload);
                        else sqf2 = (max_workload-data.maxShangquanf.workload)/(max_workload-100);
                        sqf2 = sqf2*100;
                        sqf2 = sqf2.toFixed(2);

                        var sqf3 = 100*(data.maxShangquanf.deliveryRate-min_deliveryRate)/(max_deliveryRate-min_deliveryRate);
                        sqf3 =sqf3.toFixed(2);
                        var sqf4 = 100*(data.maxShangquanf.laborProductivity-min_waybillNoCount)/(max_waybillNoCount-min_waybillNoCount);
                        sqf4 =sqf4.toFixed(2);
                        var sqf5 = 100*(data.maxShangquanf.dailyMaxWaybillCount-min_dailyMaxWaybillCount)/(max_dailyMaxWaybillCount-min_dailyMaxWaybillCount);
                        sqf5 =sqf5.toFixed(2);
                        var sqf6 = 100*(data.maxShangquanf.avgDeliveryCountRate-min_avgDeliveryCountRate)/(max_avgDeliveryCountRate-min_avgDeliveryCountRate);
                        sqf6 =sqf6.toFixed(2);

                        shangquan_max_list.push(sqf1, sqf2, sqf3, sqf4, sqf5, sqf6);


                        // 当前网点各项得分
                        var vl1 = 100*(1/now_averageAge - 1/max_averageAge) / (1/min_averageAge - 1/max_averageAge)
                        vl1 =vl1.toFixed(2);

                        var vl2;
                        if(now_workload < 100) vl2 = (now_workload-min_workload)/(100-min_workload);
                        else vl2 = (max_workload-now_workload)/(max_workload-100);
                        vl2 = vl2*100;
                        vl2 = vl2.toFixed(2);

                        var vl3 = 100*(now_deliveryRate-min_deliveryRate)/(max_deliveryRate-min_deliveryRate);
                        vl3 =vl3.toFixed(2);
                        var vl4 = 100*(now_waybillNoCount-min_waybillNoCount)/(max_waybillNoCount-min_waybillNoCount);
                        vl4 =vl4.toFixed(2);
                        var vl5 = 100*(now_dailyMaxWaybillCount-min_dailyMaxWaybillCount)/(max_dailyMaxWaybillCount-min_dailyMaxWaybillCount);
                        vl5 =vl5.toFixed(2);
                        var vl6 = 100*(now_avgDeliveryCountRate-min_avgDeliveryCountRate)/(max_avgDeliveryCountRate-min_avgDeliveryCountRate);
                        vl6 =vl6.toFixed(2);

                        value_list.push(vl1, vl2, vl3, vl4, vl5, vl6);
                        value_list.push(data.orgmonth.shangquanf);

                        var mark = document.getElementById("mark");
                        var now_mark = document.getElementById("now_mark");
                        mark.innerText = "效率评分：" + value_list[6];
                        now_mark.innerText = "评分推算效率评分" + value_list[6];

                        // 处理统计时间 (之前写在laydate change里，如果直接列表跳转year为空）
                        search_year = data.orgmonth.yuefen.substring(0,4);
                        search_month = data.orgmonth.yuefen.substring(5,7);
                        var month31 = ["01","03","05","07","08","10","12"];
                        if (month31.includes(search_month)){
                            search_day = 31;
                        }else if(search_month === "02" && parseInt(search_year)%4 === 0){
                            search_day = 29;
                        }else if(search_month === "02" && parseInt(search_year)%4 !== 0){
                            search_day = 28;
                        }else {
                            search_day = 30;
                        }


                        mychart.setOption({
                            tooltip: {},
                            legend: {
                                data: ['最优网点',$("#wangdian").val(),'评分推算'],
                                bottom: '0%'
                            },
                            radar: {

                                name: {
                                    textStyle: {
                                        color: '#fff',
                                        backgroundColor: '#999',
                                        borderRadius: 3,
                                        padding: [4, 4]
                                    }
                                },
                                indicator: [
                                    { name: '派送时效', max: 100},
                                    { name: '工作负荷', max: 100},
                                    { name: '人员利用率', max: 100},
                                    { name: '劳动生产率', max: 100},
                                    { name: '最大派送能力', max: 100},
                                    { name: '当日派件率', max: 100},
                                ],
                                center: ['50%', '47%']
                            },
                            graphic: [
                                {
                                    type: 'group',
                                    bottom: '2%',
                                    left: '78%',
                                    children: [
                                        {
                                            type: 'text',
                                            z: 100,
                                            left: 'center',
                                            top: '90%',
                                            style: {
                                                fill: '#333',
                                                text: [
                                                    '统计日期：' +search_year +'-' +(search_month) +'-' +'01'
                                                    ,'      至'+ search_year +'-' +(search_month) +'-' +search_day
                                                ].join('\n'),
                                                font: '14px Microsoft YaHei'
                                            }
                                        }
                                    ]
                                }
                            ],
                            series: [{
                                name: '当前网点 vs 最优网点',
                                type: 'radar',
                                // areaStyle: {normal: {}},
                                data: [
                                    {
                                        value: shangquan_max_list,
                                        name: '最优网点'
                                    },
                                    {
                                        value: value_list,
                                        name: $("#wangdian").val()
                                    },
                                    {
                                        value: now_valuelist,
                                        name:'评分推算'
                                    }
                                ]
                            }]
                        });

                        function updateMark() {
                            var mark = (now_dailyMaxWaybillCount - min_dailyMaxWaybillCount) / (max_dailyMaxWaybillCount - min_dailyMaxWaybillCount) * W_dailyMaxWaybillCount +
                                (1/now_averageAge - 1/max_averageAge) / (1/min_averageAge - 1/max_averageAge) * W_averageAge +
                                (now_waybillNoCount - min_waybillNoCount) / (max_waybillNoCount - min_waybillNoCount) * W_waybillNoCount+
                                (now_avgDeliveryCountRate - min_avgDeliveryCountRate) / (max_avgDeliveryCountRate-min_avgDeliveryCountRate)*W_avgDeliveryCountRate+
                                (now_deliveryRate - min_deliveryRate) / (max_deliveryRate - min_deliveryRate) * W_deliveryRate;
                            if (now_workload < 100) mark = mark +(now_workload - min_workload) / (100 - min_workload) * W_workload;
                            else mark = mark + (max_workload - now_workload) / (max_workload - 100) * W_workload;

                            mark = mark * 100;
                            mark = mark.toFixed(2);
                            if (mark > 100) {
                                mark = 100.00;
                            }
                            var now_mark = document.getElementById("now_mark");
                            now_mark.innerText = "评分推算效率评分：" + mark;
                        }

                        var ins1 = slider.render({
                                elem: '#slideTest1'
                                , max: max_dailyMaxWaybillCount
                                , min: min_dailyMaxWaybillCount
                                , value: data.orgmonth.dailyMaxWaybillCount
                                , input: false
                                , change: function (value) {
                                    now_dailyMaxWaybillCount = value;
                                    updateMark();

                                    var paidanliang = (now_dailyMaxWaybillCount-min_dailyMaxWaybillCount)/(max_dailyMaxWaybillCount-min_dailyMaxWaybillCount)
                                    paidanliang = paidanliang * 100;
                                    paidanliang = paidanliang.toFixed(2);
                                    var pdl = document.getElementById("paidanliang");
                                    pdl.innerText = "最大派送能力得分：" + paidanliang;

                                    $.ajax({
                                        async: false,
                                        success: function () {
                                            a1 = paidanliang;
                                        }
                                    })

                                    // 修改雷达图
                                    var option = mychart.getOption();
                                    option.series[0].data[2].value[4] = a1;
                                    mychart.setOption(option);
                                }
                            }
                        );
                        ins1.setValue(data.orgmonth.dailyMaxWaybillCount - min_dailyMaxWaybillCount);

                        var ins2 = slider.render({
                            elem: '#slideTest2'
                            , max: max_averageAge * 10000
                            , min: min_averageAge * 10000
                            , value: data.orgmonth.averageAge * 10000
                            , input: false
                            , setTips: function(value) {
                                return (value / 10000).toFixed(4);
                            }
                            , change: function (value) {
                                // change这里的value是setTips处理return后的值
                                now_averageAge = value;
                                updateMark();

                                var shixiao = (1/now_averageAge - 1/max_averageAge) / (1/min_averageAge - 1/max_averageAge)
                                shixiao = shixiao * 100;
                                shixiao = shixiao.toFixed(2);
                                var sx = document.getElementById("shixiao");
                                if(shixiao>100){
                                    shixiao = 100.00;
                                }  else if (shixiao <= 0) {
                                    shixiao = 0.00;
                                }
                                sx.innerText = "派送时效得分：" + shixiao;

                                $.ajax({
                                    async: false,
                                    success: function () {
                                        a2 = shixiao;
                                    }
                                })
                                var option = mychart.getOption();

                                option.series[0].data[2].value[0] = a2;
                                mychart.setOption(option);
                            }
                        });
                        ins2.setValue((data.orgmonth.averageAge-min_averageAge) * 10000);

                        var ins3 = slider.render({
                            elem: '#slideTest3'
                            , max: max_waybillNoCount * 10000
                            , min: min_waybillNoCount * 10000
                            , value: data.orgmonth.waybillNoCount * 10000
                            , input: false
                            , setTips: function(value) {
                                return (value / 10000).toFixed(4);
                            }
                            , change: function (value) {
                                now_waybillNoCount = value;
                                updateMark();

                                var danliang = (now_waybillNoCount-min_waybillNoCount)/(max_waybillNoCount-min_waybillNoCount)
                                danliang = danliang * 100;
                                danliang = danliang.toFixed(2);
                                var dl = document.getElementById("danliang");
                                dl.innerText = "劳动生产率得分：" + danliang;

                                $.ajax({
                                    async: false,
                                    success: function () {
                                        a3 = danliang;
                                    }
                                })
                                var option = mychart.getOption();

                                option.series[0].data[2].value[3] = a3;
                                mychart.setOption(option);
                            }
                        });
                        ins3.setValue((now_waybillNoCount - min_waybillNoCount) * 10000);

                        var ins4 = slider.render({
                            elem: '#slideTest4'
                            , max: max_avgDeliveryCountRate * 10000
                            , min: min_avgDeliveryCountRate * 10000
                            , value: data.orgmonth.avgDeliveryCountRate * 10000
                            , input: false
                            , setTips: function(value) {
                                return (value / 10000).toFixed(4);
                            }
                            , change: function (value) {
                                now_avgDeliveryCountRate = value;
                                updateMark();

                                var paijianlv = (now_avgDeliveryCountRate-min_avgDeliveryCountRate)/(max_avgDeliveryCountRate-min_avgDeliveryCountRate)
                                paijianlv = paijianlv * 100;
                                paijianlv = paijianlv.toFixed(2);
                                var pjl = document.getElementById("paijianlv");
                                pjl.innerText = "当日派件率得分：" + paijianlv;

                                $.ajax({
                                    async: false,
                                    success: function () {
                                        a4 = paijianlv;
                                    }
                                })
                                var option = mychart.getOption();

                                option.series[0].data[2].value[5] = a4;
                                mychart.setOption(option);
                            }
                        });
                        ins4.setValue((now_avgDeliveryCountRate-min_avgDeliveryCountRate) * 10000);

                        var ins5 = slider.render({
                            elem: '#slideTest5'
                            , max: max_deliveryRate * 10000
                            , min: min_deliveryRate * 10000
                            , value: data.orgmonth.deliveryRate * 10000
                            , input: false
                            , setTips: function(value) {
                                return (value / 10000).toFixed(4);
                            }
                            , change: function (value) {
                                now_deliveryRate = value;
                                updateMark();

                                var liyonglv = (now_deliveryRate-min_deliveryRate)/(max_deliveryRate-min_deliveryRate)
                                liyonglv = liyonglv * 100;
                                liyonglv = liyonglv.toFixed(2);
                                var lyl = document.getElementById("liyonglv");
                                lyl.innerText = "人员利用率得分：" + liyonglv;

                                $.ajax({
                                    async: false,
                                    success: function () {
                                        a5 = liyonglv;
                                    }
                                })
                                var option = mychart.getOption();

                                option.series[0].data[2].value[2] = a5;
                                mychart.setOption(option);
                            }
                        });
                        ins5.setValue((now_deliveryRate- min_deliveryRate) * 10000);


                        var ins6 = slider.render({
                            elem: '#slideTest6'
                            , max: max_workload * 10000
                            , min: min_workload * 10000
                            , value: data.orgmonth.workload * 10000
                            , input: false
                            , setTips: function(value) {
                                return (value / 10000).toFixed(4);
                            }
                            , change: function (value) {
                                now_workload = value;
                                updateMark();

                                var fuhelv = 0;
                                if(now_workload < 100) fuhelv = (now_workload-min_workload)/(100-min_workload);
                                else fuhelv = (max_workload-now_workload)/(max_workload-100);

                                fuhelv = fuhelv * 100;
                                fuhelv = fuhelv.toFixed(2);
                                var fhl = document.getElementById("fuhe");
                                fhl.innerText = "工作负荷得分：" + fuhelv;

                                $.ajax({
                                    async: false,
                                    success: function () {
                                        a6 = fuhelv;
                                    }
                                })
                                var option = mychart.getOption();

                                option.series[0].data[2].value[1] = a6;
                                mychart.setOption(option);
                            }
                        });

                        ins6.setValue((now_workload - min_workload) *10000);

                        // 重置
                        $('#reset').on('click',function(){
                            ins1.setValue(data.orgmonth.dailyMaxWaybillCount - min_dailyMaxWaybillCount);
                            ins2.setValue((data.orgmonth.averageAge-min_averageAge) * 10000);
                            ins3.setValue((data.orgmonth.laborProductivity - min_waybillNoCount)*10000);
                            ins4.setValue((data.orgmonth.avgDeliveryCountRate - min_avgDeliveryCountRate)*10000);
                            ins5.setValue((data.orgmonth.deliveryRate - min_deliveryRate) * 10000);
                            ins6.setValue((data.orgmonth.workload - min_workload) *10000);
                        })

                    }})

                // 经营建议部分
                $.ajax({
                    url: '/advice',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);
                        var eval = "<b><p style=\"margin-left: 30px;\">网点情况</p></b>" +
                            "<ul><li style='margin-left: 60px;list-style-type: disc'><p>" + data.rank + "</p></li>";
                        if (data.weak != null) {
                            eval += "<li style='margin-left: 60px;list-style-type: disc'><p>" + data.weak + "<span id='detail_info' style='color: #1D54C2'><b>详细信息>>></b></span></p>"+"</li>";
                        }
                        eval += "</ul>";
                        document.getElementById("eval").innerHTML = eval;
                        document.getElementById("load_rank").innerHTML = data.load_rank;
                        document.getElementById("staff_rank").innerHTML = data.staff_rank;
                        document.getElementById("age_rank").innerHTML = data.age_rank;
                        document.getElementById("labor_rank").innerHTML = data.labor_rank;
                        document.getElementById("daily_rank").innerHTML = data.daily_rank;
                        document.getElementById("max_rank").innerHTML = data.max_rank;

                        var advice = "<b><p style=\"margin-left: 30px;\">改正建议</p></b><ul>";
                        var advices = data.advice.split("\n");
                        for (var i = 0; i < advices.length; i++) {
                            advice += "<li style='margin-left: 60px;list-style-type: disc'><p>" + advices[i] + "</p></li>";
                        }
                        advice += "</ul>";
                        document.getElementById("advice").innerHTML = advice;

                        function A(){
                            var btn = document.getElementById('detail_info');
                            var box = document.getElementById('rank')

                            btn.onmouseover = function(){
                                box.style.display = 'block';
                            }
                            btn.onmouseout = function(){
                                box.style.display = 'none';
                            }
                        }
                        $(function (){
                                setTimeout(A(),3000);
                            }
                        )
                    }
                })
            })


            // 熵权法得分趋势图
            //执行一个laydate实例
            laydate.render({
                elem: '#yuefenRange' //指定元素
                ,type: 'month'
                ,range: true
                ,max: 0
                ,value: '[[${yuefenRange}]]'
            });

            option = {
                xAxis: {
                    type: 'category',
                    data: [],
                    axisLine: {
                        lineStyle: {
                            type: 'solid',
                            color: '#4c84ff',//左边线的颜色
                            width:'1'//坐标线的宽度
                        }

                    },
                    axisLabel: {
                        textStyle: {
                            color: '#000',//坐标值得具体的颜色
                        }
                    }
                },
                yAxis: {
                    type: 'value',
                    axisLine: {show:false},
                    axisTick: {show:false},
                },
                tooltip: {
                    trigger: 'axis'
                },
                series: [{
                    data: [],
                    type: 'line',
                    symbol: 'circle',
                    symbolSize: 2,
                    lineStyle: {
                        width: 2
                    },
                    itemStyle: {
                        borderWidth: 2,
                        borderColor: '#4C84FF',
                        color: '#4C84FF'
                    }
                }
                ]
            };

            shangquanf_chart= echarts.init(document.getElementById('shangquanf_chart'));
            shangquanf_chart.setOption(option);

            form.on('submit(LAY-app-contlist-search4)', function(data){
                data.field['wangdian'] = document.getElementById("wangdian").value;
                $.ajax({
                    url:'/get_evaluate?type=shangquanf',
                    async: false,
                    type:"POST",
                    dataType: "text",
                    data:data.field,
                    success:function(data){
                        data=$.parseJSON(data);

                        if(data.res.toString()!=='fail'){
                            shangquanf_chart.setOption({
                                // title: {
                                //     text: '熵权法分数'
                                // },
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.yuefen,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.shangquanf,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }
                                }]
                            });
                        }else{
                            layer.open({
                                title: '查询失败'
                                ,content: '未查询到相关记录！'
                            });
                        }
                    }})
            })

            // 各指标变化趋势图
            //执行一个laydate实例
            laydate.render({
                elem: '#date' //指定元素
                , range: true
                ,max: 0
                ,value: '[[${date}]]'
            });

            option = {
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    type: 'category',
                    data: [],
                    axisLine: {
                        lineStyle: {
                            type: 'solid',
                            color: '#4c84ff',//左边线的颜色
                            width:'1'//坐标线的宽度
                        }

                    },
                    axisLabel: {
                        textStyle: {
                            color: '#000',//坐标值得具体的颜色
                        }
                    }
                },
                yAxis: {
                    type: 'value',
                    axisLine: {show:false},
                    axisTick: {show:false},
                },
                series: [{
                    data: [],
                    type: 'line',
                    symbol: 'circle',
                    smooth: true,
                    lineStyle: {
                        color: '#4C84FF',
                        width: 2
                    },
                    itemStyle: {
                        borderWidth: 2,
                        borderColor: '#4C84FF',
                        color: '#4C84FF'
                    }
                }]
            };


            shixiao_chart = echarts.init(document.getElementById('shixiao_chart'));
            shixiao_chart.setOption(option);
            workLength_chart = echarts.init(document.getElementById('workLength_chart'));
            workLength_chart.setOption(option);
            shengchanlv_chart = echarts.init(document.getElementById('shengchanlv_chart'));
            shengchanlv_chart.setOption(option);
            // yewuliang_chart = echarts.init(document.getElementById('yewuliang_chart'));
            // yewuliang_chart.setOption(option);
            deliveryCount_chart = echarts.init(document.getElementById('deliveryCount_chart'));
            deliveryCount_chart.setOption(option);
            deliveryCountOfDay_chart = echarts.init(document.getElementById('deliveryCountOfDay_chart'));
            deliveryCountOfDay_chart.setOption(option);
            deliveryCountRate_chart = echarts.init(document.getElementById('deliveryCountRate_chart'));
            deliveryCountRate_chart.setOption(option);

            form.on('submit(LAY-app-contlist-search3)', function (data) {
                data.field['wangdian'] = document.getElementById("wangdian").value;
                data.field['date'] = document.getElementById("date").value;

                // 当日派件率趋势图
                $.ajax({
                    url: '/get_evaluate?type=deliveryCountRate',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);
                        if (data.res.toString() !== 'fail') {
                            deliveryCountRate_chart.setOption({
                                tooltip : {
                                    trigger: 'axis',
                                    formatter:function(params) {
                                        var relVal = "";
                                        for (var i = 0, l = params.length; i < l; i++) {
                                            relVal += params[i].marker + params[i].name + ':' + params[i].value.toFixed(2) + '% '
                                        }
                                        return relVal;
                                    }
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.date,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.deliveryCountRate,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }
                                }]
                            });
                        } else {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }
                    }
                })

                // 当日派件量趋势图
                $.ajax({
                    url: '/get_evaluate?type=deliveryCountOfDay',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);
                        if (data.res.toString() !== 'fail') {
                            deliveryCountOfDay_chart.setOption({
                                tooltip: {},
                                xAxis: {
                                    type: 'category',
                                    data: data.date,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.deliveryCountOfDay,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }
                                }]
                            });
                        } else {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }
                    }
                })

                // 人员利用率趋势图
                $.ajax({
                    url: '/get_evaluate?type=deliveryCount',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);
                        if (data.res.toString() !== 'fail') {
                            deliveryCount_chart.setOption({
                                tooltip : {
                                    trigger: 'axis',
                                    formatter:function(params) {
                                        var relVal = "";
                                        for (var i = 0, l = params.length; i < l; i++) {
                                            relVal += params[i].marker + params[i].name + ':' + params[i].value.toFixed(2) + '% '
                                        }
                                        return relVal;
                                    }
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.date,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.deliveryCount,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }
                                }]
                            });
                        } else {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }
                    }
                })

                // 劳动生产率趋势图
                $.ajax({
                    url: '/get_evaluate?type=shengchanlv',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);
                        if (data.res.toString() !== 'fail') {
                            shengchanlv_chart.setOption({
                                tooltip: {
                                    trigger: 'axis'
                                },
                                tooltip : {
                                    trigger: 'axis',
                                    formatter:function(params) {
                                        var relVal = "";
                                        for (var i = 0, l = params.length; i < l; i++) {
                                            relVal += params[i].marker + params[i].name + ':' + params[i].value.toFixed(2);
                                        }
                                        return relVal;
                                    }
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.date,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.shengchanlv,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }
                                }]
                            });
                        } else {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }
                    }
                })

                // 工作负荷趋势图
                $.ajax({
                    url: '/get_evaluate?type=workLength',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);
                        if (data.res.toString() !== 'fail') {
                            workLength_chart.setOption({
                                tooltip : {
                                    trigger: 'axis',
                                    formatter:function(params) {
                                        var relVal = "";
                                        for (var i = 0, l = params.length; i < l; i++) {
                                            relVal += params[i].marker + params[i].name + ':' + params[i].value.toFixed(2) + '% '
                                        }
                                        return relVal;
                                    }
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.date,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.worklength,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }

                                }]
                            });
                        } else {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }
                    }
                })

                // 派送时效趋势图
                $.ajax({
                    url: '/get_evaluate?type=shixiao',
                    async: false,
                    type: "POST",
                    dataType: "text",
                    data: data.field,
                    success: function (data) {
                        data = $.parseJSON(data);

                        if (data.res.toString() !== 'fail') {
                            shixiao_chart.setOption({
                                tooltip: {
                                    trigger: 'axis'
                                },
                                xAxis: {
                                    type: 'category',
                                    data: data.date,
                                    axisLine: {
                                        lineStyle: {
                                            type: 'solid',
                                            color: '#4c84ff',//左边线的颜色
                                            width:'1'//坐标线的宽度
                                        }

                                    },
                                    axisLabel: {
                                        textStyle: {
                                            color: '#000',//坐标值得具体的颜色
                                        }
                                    }
                                },
                                yAxis: {
                                    type: 'value',
                                    axisLine: {show:false},
                                    axisTick: {show:false},
                                },
                                series: [{
                                    data: data.Shixiao,
                                    type: 'line',
                                    symbol: 'circle',
                                    showSymbol: false,
                                    lineStyle: {
                                        color: '#4C84FF',
                                        width: 2
                                    },
                                    itemStyle: {
                                        borderWidth: 2,
                                        borderColor: '#4C84FF',
                                        color: '#4C84FF'
                                    }
                                }]
                            });
                        } else {
                            layer.open({
                                title: '查询失败'
                                , content: '未查询到相关记录！'
                            });
                        }
                    }
                })
            })

        }
    );
</script>
</body>
</html>
